package cn.com.io.day20151210;

import java.io.IOException;
import java.io.PrintStream;

/**
 * Created by Administrator on 2015/12/10.
 */
public class WriteToProcess {
    public static void main(String[] args){
        PrintStream print = null;
        try {
            Process process =Runtime.getRuntime().exec("java ReadStandard");//运行java ReadStandard命令，返回运行该命令的子进程
            print = new PrintStream(process.getOutputStream());//以process进程的输出流创建PrintStream对象，这个输出流对本程序是输出流，对precess则是输入流
            print.println("普通字符串");//向ReadStandard写入内容，这些内容将被ReadStandard读取
            print.println(new WriteToProcess());
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if (print !=null){
                print.close();
            }
        }
    }

}
